The ANSI C specification requires a collection of standard functions for the manipulation of character strings. However, these do not include some of themore useful functions found in the
String
and
Gen_String
classes. In addtion, many generic character string functions c
an be used for the
String
and
Gen_String
objects because of the implicit
operator char*\f1.
For these reasons, the following auxiliary functions are defined for the built-in
Removes any prefix occurrence of the second character string \f2str2\f1 in the first character string \f2sztr1\f1. This function returns a pointer to the modified character string \f2str1\f1.
Removes any suffix occurrence of the second character string \f2str2\f1 in the first character string \f2str1\f1. This function returns a pointer to the modified character string \f2str1\f1.
This function provides simple pattern matching by scanning from left to right
through \f2str1\f1 for the first occurrence of \f2str2\f1. An asterisk can be used to match for zero or more characters and a question mark can be used to match for any single character. This function returns a pointer to the start of the matching character string and updates the zero-relative \f2start\f1 and \f2end\f1 indexes if found; otherwise, this function returns
This function provides simple pattern matching by scanning from right to left
through \f2str1\f1 for the first occurrence of \f2str2\f1. An asterisk can be used to match for zero or more characters and a question mark can be used to match for any single character. This function returns a pointer to the start of the matching character string and updates the zero-relative \f2start\f1 and \f2end\f1 indexes if found; otherwise, this function returns
NULL .
.TP
\f3char* strndup (const char* \f2str\f3, long \f2position\f3);\f1
Duplicates into a new character string allocated off the heap the sequence of
characters from the beginning of \f2str\f1 to the zero-relative index \f2position\f1. This function returns a pointer to the duplicated character string if successful; otherwise, this function returns
NULL
if the index is out of range.
.TP
\f3char* strnremove (char* \f2str\f3, long \f2position\f3);\f1
Removes the sequence of characters from the beginning of \f2str\f1 to the
zero-relative index \f2position\f1. This function returns a pointer to the new
character string if successful; otherwise, this function returns
NULL
if the index is out of range.
.TP
\f3char* stryank (char* \f2str\f3, long \f2position\f3);\f1
Deletes the sequence of characters from the beginning of \f2str\f1 to the
zero-relative index \f2position\f1 and allocates a new character string off the heap whose value is the deleted characters. This function returns a pointer to the yanked string if successful; otherwise, this function returns
NULL
if the index is out of range.
.TP
\f3void reverse (char* \f2str\f3);\f1
Reverses the order of characters in a string \f2str\f1.